package com.ruoyi.rsikManage.mapper;

import com.ruoyi.rsikManage.domain.CoalMine;
import com.ruoyi.rsikManage.domain.MonitorPoint;
import com.ruoyi.rsikManage.domain.VideoResourceTreeNode;
import com.ruoyi.rsikManage.domain.vo.*;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.*;
@Mapper
public interface MonitorPointMapper {
    int updateMonitorOfflineAlarmSettings(MonitorsOfflineAlarmSettings monitorOfflineAlarmSettings);

    int updateOfflineTimeOutMinutes(Integer setMinutes);
    int insertMonitorPoints(List<MonitorPoint> monitorPointList);
    HashMap<String, Integer> selectTotalMonitorCountAndOnlineMonitorCount();

    HashMap<String, Integer> selectMonitorStatusCount( @Param("unitCode")Long unitCode,@Param("unitCodes")List<Long> unitCodes);

    HashMap<String, Integer> selectTotalMonitorCountAndOnlineMonitorCountForUnitCodes(@Param("apeIds")List<String> apeIds,
                                                                                      @Param("unitCodes")List<Long> unitCodes);

    List<MonitorPoint> selectMonitorPointsInPlace(@Param("placeId") Long placeId);

    List<MonitorPoint> selectMonitorsDetail(@Param("monitorPoint") MonitorPoint monitorPoint,
                                            @Param("treeNode") VideoResourceTreeNode treeNode);

    List<MonitorPoint> selectMonitorsDetailForUnitCodes(@Param("monitorPoint") MonitorPoint monitorPoint);
    MonitorPoint selectMonitorByApeId(@Param("apeId") String apeId);
    List<MonitorPoint> selectAllMonitorPoints();
    List<MonitorPoint> selectAllMonitorPointsGroup(@Param("unitCode") Long unitCode);

    List<MonitorPoint> selectAllMonitorPointsForUnitCodes();
    List<MonitorPoint> selectAllMonitorPoints2(MonitorPoint monitorPoint);

    List<MonitorPointDiagnosisResultVo> selectMonitorsDiagnosisResult(@Param("treeType") String treeType, @Param("resourceTreeNodeId") Integer resourceTreeNodeId, @Param("diagnosisResult") String diagnosisResult, @Param("diagnosisStartTime") Date diagnosisStartTime, @Param("diagnosisEndTime") Date diagnosisEndTime, @Param("monitorPointName")String monitorPointName);

    List<MonitorPointDiagnosisResultVo> selectMonitorsDiagnosisResult2(@Param("treeType") String treeType, @Param("resourceTreeNodeId") Integer resourceTreeNodeId,
                                                                       @Param("diagnosisResult") String diagnosisResult, @Param("diagnosisStartTime") Date diagnosisStartTime,
                                                                       @Param("colorCast") String[] colorCast, @Param("contrastRatio") String[] contrastRatio,
                                                                       @Param("crossStriation") String[] crossStriation, @Param("highLuminance") String[] highLuminance,
                                                                       @Param("freeze") String[] freeze, @Param("jitter") String[] jitter,
                                                                       @Param("loss") String[] loss, @Param("lowLuminance") String[] lowLuminance,
                                                                       @Param("noise") String[] noise, @Param("occlusion") String[] occlusion,
                                                                       @Param("transverseWave") String[] transverseWave, @Param("rollingStripe") String[] rollingStripe,
                                                                       @Param("sceneChange") String[] sceneChange, @Param("stripe") String[] stripe,
                                                                       @Param("diagnosisEndTime") Date diagnosisEndTime, @Param("monitorPointName")String monitorPointName);
    //    List<MonitorPoint> selectMonitorPointsByResourceTreeNode();
    int deleteAllMonitorPoint();
    int deleteTheTreeNodeAndAllMonitorsRel(Integer nodeId);
    List<MonitorPoint> selectMonitorPointsInApeIdSet(HashSet<String> apeIdSet);
    int addMonitorAndTreeNodeRel(@Param("monitorId") String monitorId,@Param("nodeId") Integer nodeId);
    HashSet<Integer> selectNodeIdsInSameTree(@Param("nodeId") Integer nodeId);
    int delMonitorAndNodeRelInTheIdSet( @Param("monitorId") String monitorId, @Param("nodeIdSet") HashSet nodeIdSet);
    int updateStandPlaceItBelongs(@Param("monitorId") String monitorId,@Param("standPlaceId") Long standPlaceId);
    int deleteMonitorRelStandPlace(Long[] standPlaceIds);

    int insertMonitorPoint(MonitorPoint monitor);

    int insertMonitorOfflineRecord(@Param("monitorId") String monitorId, @Param("offlineTime") Date offlineTime);

    int updateMonitorStatus(MonitorPoint monitor);

    List<HistogramVo> selectCameraType();

    List<HistogramVo> selectCameraTypeWithMonitorNumber();

    List<HistogramVo> selectCameraTypeWithMonitorNumberForUnitCodes(@Param("unitCodes")List<Long> unitCodes);


    int selectMonitorNumberOfCameraType(String cameraTypeDicVal);

    int countMonitorByIsOnline(String isOnlineDicVal);

    int countMonitorByIsOnlineForUnitCodes(@Param("isOnlineDicVal") String isOnlineDicVal,@Param("unitCodes")List<Long> unitCodes);


    int countMonitorByDiagnosisResult(String diagnosisResult);


    List<MonitorPoint> selectMonitorPoints(String monitorName);

    List<CoalMine> selectCoalMines();

    List<MonitorPoint> selectMonitorsInCoalMine(String coalMineName);

    int countOnlineMonitorInCoalMine(String coalMineName);

    int deleteMonitorByApeId(@Param("monitorId") String monitorId);

    List<CoalMine> selectCoalMinesWithMonitors(String monitorName);

    List<CoalMine> selectCoalMinesWithMonitorsForUnitCodes(@Param("unitCode") Long unitCode,@Param("monitorName") String monitorName,
                                                           @Param("isOnline") String isOnline, @Param("unitCodes")List<Long> unitCodes);

    int mergeMonitorListToMonitorTable(@Param("monitorPointList") List<MonitorPoint> monitorPointList);

    void deleteMonitorNotInList(List<MonitorPoint> list);
    @MapKey("apeId")
    HashMap<String, MonitorPoint> selectMonitorMapByList(@Param("monitorIdList") List<String> monitorIdList);
    Integer selectOfflineTimeOutMinutes();

    List<MonitorPoint> selectMonitorsThatNeedToSendOfflineAlarm();

    List<MonitorPoint> selectMonitorsOfflineTimeoutList();


    int insertMonitorOfflineAlarm(@Param("monitorListThatOfflineTimeout") List<MonitorPoint> monitorListThatOfflineTimeout);

    int insertMonitorOfflineAlarmForUnitCodes(@Param("monitorListThatOfflineTimeout") List<MonitorPoint> monitorListThatOfflineTimeout);


    int updateAlarmStatusAsSent(@Param("monitorListThatOfflineTimeout") List<MonitorPoint> monitorListThatOfflineTimeout);

    int updateAlarmStatusAsSentForUnitCodes(@Param("monitorListThatOfflineTimeout") List<MonitorPoint> monitorListThatOfflineTimeout);

    int selectIfOfflineTimeoutAlarmIsEnabled();

    MonitorsOfflineAlarmSettings selectMonitorOfflineAlarmSettings();

    List<MonitorPointVO> selectAllMonitors();

    List<MonitorPointVO> selectAllMonitorsForUnitCodes( MonitorPoint monitorPoint);

    List<GisMonitorsVo> selectAllGisMonitors(GisMonitorsVo gisMonitorsVo);

    List<GisMonitorsVo> gisMonitorsHasCoordinates();

    void updateGisMonitorsCoordinates(GisMonitorsVo gisMonitorsVo);

    List<MonitorPoint> selectMonitorsThatDropLine();

    List<MonitorPoint> selectMonitorsThatDropLineForUnitCodes();

    void recordDropLineMonitorList(@Param("dropLineMonitors")List<MonitorPoint> dropLineMonitors);

    void recordDropLineMonitorListForUnitCodes(@Param("dropLineMonitors")List<MonitorPoint> dropLineMonitors);

    // 检查在指定时间段内是否存在特定的监控点记录
    boolean existsInCurrentHour(@Param("startTime")LocalDateTime startTime, @Param("endTime")LocalDateTime endTime,
                                @Param("unitCode")Long unitCode, @Param("monitorId")String monitorId);


    void updateMonitors3DCoordinates(GisMonitors3DVo gisMonitors3DVo);

    List<GisMonitors3DVo> gisMonitorsHas3DCoordinates();

    List<GisMonitors3DVo> selectAllMonitors3D(GisMonitors3DVo gisMonitors3DVo);

    List<MonitorOfflineAlarmSettingRespVo> selectMonitorsOfflineAlarmSettingTime(MonitorOfflineAlarmSettingRespVo monitorOfflineAlarmSettingRespVo);

    void updateOfflineAlarmSettingTime(MonitorOfflineAlarmSettingResqVo monitorOfflineAlarmSettingResqVo);
}
